/*
 * Copyright (c) 2001, 2002 Boris Pruessmann and others.
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Common Public License v0.5
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v05.html
 * 
 * Contributors:
 *    Boris Pruessmann - Initial implementation.
 */
package net.sourceforge.perforce.core.syncinfo;

import java.io.Serializable;

import net.sourceforge.perforce.core.internal.Policy;

/**
  * @version $Revision: 81 $
  * @author  <a href="mailto:bpruessmann@users.sourceforge.net">Boris Pruessmann</a>
  */
public class FolderSyncInfo implements Serializable
{
	// --------------------------------------------------------------------------- Private Variables
	
	/** Stores the depot filename. */
	private String depotFileName;
	/** Indicates that the folder is added. */
	private boolean added;

	// ------------------------------------------------------------------------- Public Constructors

	/** Constructor for FolderSyncInfo. */
	public FolderSyncInfo()
	{
		this(null);
	}

	/** Constructor for FolderSyncInfo.
	  *  
	  * @param depotFileName the depot filename.
	  */
	public FolderSyncInfo(String depotFileName)
	{
		this(depotFileName, false);
	}

	/** Constructor for FolderSyncInfo.
	  *  
	  * @param depotFileName the depot filename.
	  * @param added indicates a new folder.
	  */
	public FolderSyncInfo(String depotFileName, boolean added)
	{
		this.depotFileName = depotFileName;
		this.added = added;
	}


	// ------------------------------------------------------------------------------ Public Methods

	/** Gets the depotFileName.
	  * 
	  * @return Returns a String
	  */
	public String getDepotFileName()
	{
		return depotFileName;
	}

	/** Sets the depotFileName.
	  * 
	  * @param depotFileName The depotFileName to set
	  */
	public void setDepotFileName(String depotFileName)
	{
		Policy.assertNotNull(depotFileName);
		this.depotFileName = depotFileName;
	}
	
	/** Checks whether the Folder is added.
	  * 
	  * @return true if folder is new, false otherwise.
	  */
	public boolean isAdded()
	{
		return added;
	}
	
	/** @see java.lang.Object#equals(java.lang.Object) */
	public boolean equals(Object other) 
	{
		if (this == other)
		{
			return true;
		}
		
		
		if (!(other instanceof FolderSyncInfo))
		{
			return false;
		}
		
		FolderSyncInfo otherSyncInfo = (FolderSyncInfo) other;
		return 
			getDepotFileName().equals(otherSyncInfo.getDepotFileName()) &&
			isAdded() == otherSyncInfo.isAdded();
	}
	
	/** @see java.lang.Object#hashCode() */
	public int hashCode() 
	{
		return getDepotFileName().hashCode();
	}

}
